using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Slot : MonoBehaviour
{
    public int i;
    private Inventory _inventory;
    
    void Start()
    {
        _inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();
    }


    //实现点击叉扔掉物品功能
    public void Drop()
    {
        foreach (Transform child in transform)  //取slot的子物体，因为捡起的物品全部实例化为slot的子物体了
        {
            child.GetComponent<Spawn>().SpawnDropedItem();  //在世界地图上放回物品
            Destroy(child.gameObject);
            _inventory.isFull[i] = false;       //将当前背包格子重置为空背包
        }
    }
}
